require 'watir'
include Watir
require 'test/unit'
class TC_blogsFrontEnd < Test::Unit::TestCase
  	def test_21_ModifyPage_Blogs

    $ie.goto($UniVar)

#Create Blog
    $ie.goto($UniVar + '/controlpanel/BlogAdmin/sectionedit.aspx')
    $ie.wait()    
    $ie.text_field(:index, 1).set('watir blog')
    $ie.text_field(:index, 2).set('watirblog')
    $ie.text_field(:index, 3).set($ADMIN)
    $ie.link(:text, 'Save').click    

#test specifics
	temp_var = "watir test page body"
  $ie.goto($UniVar + '/ControlPanel/Blogs/posteditor.aspx?SelectedNavItem=NewPage&bpt=2')
	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostSubject/).set('Watir Test Page')
  $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")        
#	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostBody___Editor/).set('Watir Test Body')
	$ie.link(:text, 'Publish').click
  $ie.link(:text, 'Watir Test Page').click
  
	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostSubject/).clear
  $ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostSubject/).set('Watir Test Page Change')
	$ie.link(:text, 'Publish').click
  assert($ie.contains_text('Watir Test Page Change'))

#Delete Blog    
        $ie.goto($UniVar + '/controlpanel/BlogAdmin/Blogs.aspx')
        $ie.wait()
        $ie.link(:text, 'Delete').click_no_wait
        hwnd = $ie.enabled_popup(20)
          if(hwnd)
            w = WinClicker.new
            w.clickWindowsButton_hwnd(hwnd, "OK")
          end    
end
end